package com.dn.luckbi.bizmq;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author 染染熊
 * @version 1.0
 * @date 2024/3/28 17:28
 */

@Component
public class MyMessageProducer {

    @Resource
    private RabbitTemplate rabbitTemplate;

    /**
     * 发送消息到RabbitMQ
     *
     * @param exchangeName
     * @param routingKey
     * @param message
     */
    public void sendMessage(String exchangeName, String routingKey, String message) {
        // 发送消息
        rabbitTemplate.convertAndSend(exchangeName, routingKey, message);
    }

    /**
     * 发送消息到RabbitMQ
     *
     * @param message
     */
    public void sendMessage(String message) {
        // 发送消息
        rabbitTemplate.convertAndSend(MyMqConstant.EXCHANGE, MyMqConstant.ROUTING_KEY, message);
    }


}
